package spring.batch.shareDataHolder;

import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import spring.batch.readFile.People;

import java.util.Date;

/**
 * @Author: huhx
 * @Date: 2017-11-03 上午 9:00
 */
public class SetDataHolderTasklet implements Tasklet {
    private ImportMetadataHolder importMetadataHolder;

    public void setImportMetadataHolder(ImportMetadataHolder importMetadataHolder) {
        this.importMetadataHolder = importMetadataHolder;
    }

    @Override
    public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
        People people = new People();
        people.setUsername("huhx");
        people.setBirthday(new Date());
        people.setAddress("武汉");
        people.setAge(23);
        importMetadataHolder.setPeople(people);
        return RepeatStatus.FINISHED;
    }
}
